color editor: stop using ::focus-out-event
authorMatthias Clasen <mclasen@redhat.com>
Sat, 6 Jan 2018 20:35:54 +0000 (15:35 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 16 Jan 2018 19:14:10 +0000 (14:14 -0500)
Again, the has-focus property is sufficient.

gtk/gtkcoloreditor.c
gtk/ui/gtkcoloreditor.ui

index 2fc1bd46a681ecce4c0a8082ed2ea59e39c861e5..9bf2108efc5abb47313f1deffd813d6393ba8d94 100644 (file)
@@ -126,13 +126,13 @@ entry_apply (GtkWidget      *entry,
   g_free (text);
 }
 
-static gboolean
-entry_focus_out (GtkWidget      *entry,
-                 GdkEventFocus  *event,
-                 GtkColorEditor *editor)
+static void
+entry_focus_changed (GtkWidget      *entry,
+                     GParamSpec     *pspec,
+                     GtkColorEditor *editor)
 {
-  entry_apply (entry, editor);
-  return FALSE;
+  if (!gtk_widget_has_focus (entry))
+    entry_apply (entry, editor);
 }
 
 static void
@@ -487,7 +487,7 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
   gtk_widget_class_bind_template_callback (widget_class, get_child_position);
   gtk_widget_class_bind_template_callback (widget_class, entry_text_changed);
   gtk_widget_class_bind_template_callback (widget_class, entry_apply);
-  gtk_widget_class_bind_template_callback (widget_class, entry_focus_out);
+  gtk_widget_class_bind_template_callback (widget_class, entry_focus_changed);
   gtk_widget_class_bind_template_callback (widget_class, popup_edit);
 }
 
index 725231e3c3fee019bf040a2990af0ef53b72d777..c38f7715117d008ac4d283a3eba15beaa5436270 100644 (file)
@@ -60,7 +60,7 @@
                   </object>
                 </child>
                 <signal name="activate" handler="entry_apply" swapped="no"/>
-                <signal name="focus-out-event" handler="entry_focus_out" swapped="no"/>
+                <signal name="notify::has-focus" handler="entry_focus_changed" swapped="no"/>
                 <signal name="notify::text" handler="entry_text_changed" swapped="no"/>
               </object>
               <packing>